package tree;

/**
 * @author way
 * @create 2025-02-13 12:38
 */
public class _98_isValidBST {
    int prev = Integer.MIN_VALUE;

    public boolean isValidBST(TreeNode root) {
        if (root == null) return false;

        if (!isValidBST(root.left)) {
            return false;
        }
        if (root.val <= prev) {
            return false;
        }
        prev = root.val;
        return isValidBST(root.right);
    }
}
